package org.snail.chat.service.chatchain.chain;

import lombok.NonNull;
import lombok.extern.log4j.Log4j;
import org.apache.log4j.Logger;
import org.snail.chat.service.chatchain.dao.ChatCreateOrUpdateDAO;
import org.snail.dept.bean.TreeNode;

import java.util.Map;

/**
 * 底层部门创建群组，根据层级来定，只需要创建最后一层层级关系
 */
@Log4j
public class SubLevelChatCreateOrUpdateHandler extends ChatCreateOrUpdateHandler {

    private final Logger LOGGER = Logger.getLogger(CurrentLevelChatCreateOrUpdateHandler.class);

    @Override
    public void doCreateOrUpdate(@NonNull TreeNode treeNode, @NonNull Map<String, ChatCreateOrUpdateDAO> chatCreateOrUpdateDAOMap) throws Exception {

        log.info("treeNode : " + treeNode + ", treeNode.getChildren() : " + treeNode.getChildren());
        //前面是将所有群组创建了，这里剔除不需要的群组
        if (null != treeNode.getChildren()) {
            log.error("treeNode : " + treeNode);
            chatCreateOrUpdateDAOMap.remove(treeNode.getId());
            log.error("chatCreateOrUpdateDAOMap : " + chatCreateOrUpdateDAOMap.get(treeNode.getId()));

        }

    }

}
